// import { userInfo } from '@/api/user'
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

import { userInfo } from '@/api/user.js'

export default new Vuex.Store({
  state: {
    //存储用户信息
    userInfo:{},
  },
  getters: {
  },
  mutations: {
    //修改用户信息
    setUserInfo(state,payload){
      state.userInfo=payload
    },
  },
  //发送异步请求
  actions: {
    //获取个人信息
    getUserInfo({commit}){
      userInfo().then(res=>{
        console.log(res);
        commit("setUserInfo",res.data)
      })
    }
  },
  modules: {
  }
})
